#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
        x=10; y=20; radius=90;gradd=0;
}
Dialog::~Dialog()
{
    delete ui;
}
//////////////////////////////////////////////////
void Dialog::keyPressEvent(QKeyEvent *event)
{

    switch (event->key())
    {
    case Qt::Key_Up: if(y-radius<0)
        {
            y--; update();
        }
        break;
    case Qt::Key_Down: if(y+radius<600)
        {
            y++; update();
        }
        break;
    case Qt::Key_Left: if(x-radius<0)
        {
            x--; update();
        }
        break;
    case Qt::Key_Right: if(x+radius<800)
        {
            x++; update();
        }
        break;
    case Qt::Key_0: if(radius<500)

        {
            radius+=5; update();
        }
        break;
    case Qt::Key_1: if(radius>5)
        {
            radius-=5; update();
        }
        break;
    case Qt::Key_G:
        {
            gradd=(gradd+1)%4; update();
        }
        break;
    case Qt::Key_Y:
        {

        }
        break;


}}


void Dialog::paintEvent(QPaintEvent *e)
{
   QPainter painter (this);
  QRadialGradient grad2(QPoint(100,150),280);
    grad2.setColorAt(1.0,Qt::black);
  grad2.setColorAt(0.1,Qt::red);
  painter.setBrush(grad2);
  painter.drawEllipse(x,y,radius,radius);

}

